package org.dxy.domain.event.equipment;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Value;
import org.dxy.domain.event.AggregateTypeEnum;
import org.dxy.domain.event.DomainEvent;

import java.time.LocalDateTime;

/**
 * 设备状态变更事件
 * @author dxy
 * @createTime 2025/6/16 0:11
 */
@Value
@Builder
@AllArgsConstructor
public class EquipmentStatusChangedEvent implements DomainEvent {
    Long equipmentId;
    String previousStatus;   // 变更前状态
    String currentStatus;    // 变更后状态
    Long workOrderId;        // 当前工单 ID
    String position;         // 所在位置（如"产线1-工位3"）
    @Builder.Default
    LocalDateTime changedTime = LocalDateTime.now();
    
    @Override
    public Long aggregateId() {
        return equipmentId;
    }
    
    @Override
    public String aggregateType() {
        return AggregateTypeEnum.EQUIPMENT.getKey();
    }
    
    @Override
    public String eventType() {
        return EquipmentEventTypeEnum.STATUS_CHANGED.getKey();
    }
}